package com.deanlib.cabinet.data.network.request;

import com.deanlib.cabinet.data.model.Download;
import com.deanlib.cabinet.data.model.Key;
import com.deanlib.cabinet.data.model.Login;
import com.deanlib.cabinet.data.model.Resource;
import com.deanlib.cabinet.data.network.Response;
import com.deanlib.cabinet.data.network.annotation.DynamicTimeout;

import java.util.List;

import io.reactivex.Observable;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;

/**
 * 封装请求的接口
 */

public interface Request {

//    @POST("?service=User.getList")
//    Observable<Response<List<JavaBean>>> getList(@Query("userId") String userId);

    @POST("api/user/login")
    Observable<Response<Login>> doLogin(@Query("key") String username, @Query("value") String password);

    @POST("api/user/register")
    Observable<Response<Login>> doRegister(@Query("key") String username, @Query("password") String password);

    @GET("api/resource/list")
    Observable<Response<List<Resource>>> getResourceList(@Query("pageNum") Integer pageNum, @Query("pageSize") Integer pageSize);

    @GET("api/resource/list_by_create_time")
    Observable<Response<List<Resource>>> getResourceListByCreateTime(@Query("resCreateTime") Long resCreateTime, @Query("pageSize") Integer pageSize);

    @GET("api/resource/package")
    @DynamicTimeout(connectTimeout = 5000, readTimeout = 60000)
    Observable<Response<Download>> getResourcePackage(@Query("startResourceId") Long startResourceId, @Query("shared") Boolean shared);

    @POST("api/resource/save")
    Observable<Response<Resource>> doSaveResource(@Body Resource resource);

    @POST("api/resource/update/path_and_bitrate")
    Observable<Response<Resource>> doUpdateResourcePathAndBitrate(@Query("md5") String md5
                                                                  , @Query("newMd5") String newMd5
            , @Query("path") String path, @Query("bitrate") Long bitrate);

    @GET("api/config/key/oss")
    Observable<Response<Key>> getConfigKeyOss();

    @POST("api/resource/get_or_save")
    Observable<Response<Resource>> doGetResourceOrSave(@Body Resource resource);
}
